package com.example.reagent_management.ui.operatedialog.repository

import androidx.paging.Pager
import androidx.paging.PagingConfig
import com.example.reagent_management.room.dao.ReagentInDao
import com.example.reagent_management.room.entity.ReagentInfoQuery
import com.example.reagent_management.room.entity.ReagentInformation
import javax.inject.Inject
import javax.inject.Singleton

//试剂信息唯一数据源
@Singleton
class ReagentRepository @Inject constructor(private val reagentInDao: ReagentInDao) {

    fun insert(reagentInformation: ReagentInformation): Long {
       return reagentInDao.insertReagentInformation(reagentInformation)
    }

    fun getAll() = Pager(
        config = PagingConfig(
            pageSize = 20,
            enablePlaceholders = false,
            maxSize = 100
        )
    ) {
        reagentInDao.getAllReagent()
    }

    fun queryReagentById(id:Long): ReagentInfoQuery {
        return reagentInDao.getReagentById(id)
    }

    /**
     * 删除
     */
    fun deleteById(id: Long):Int{
        return reagentInDao.deleteById(id)
    }

    fun update(info:ReagentInformation):Int{
        return reagentInDao.update(info)
    }


}